package com.deyuanyun.pic.ctrl.enumeration;

import com.deyuanyun.pic.ctrl.annotation.AutoEnum;

/**
 * 交流干扰源类型
 *
 * @author scalpel.王敏
 * @version [v1.0] 创建时间（2016/9/12）
 * @see // 引用的类
 * Method List:
 * 1.----------------
 * 2.----------------
 * History:
 */
@AutoEnum(name = "交流干扰源类型", method = "getVal")
public enum AcInterferenceSourceTypeEnum {

    THVACTS("高压交流输电系统"),
    ACERS("交流电气化铁路系统"),
    OCEF("其他交流用电设施");

    private String label;

    private AcInterferenceSourceTypeEnum(String label) {
        this.label = label;
    }

    public String getLabel() {
        return label;
    }

    public static String getVal(String lable) {

        AcInterferenceSourceTypeEnum rs[] = AcInterferenceSourceTypeEnum.values();
        for (int i = 0, end = rs.length; i < end; i++) {
            if (rs[i].getLabel().equals(lable)) {
                return rs[i].toString();
            }
        }
        return null;
    }

    /**
     *老王我加一个方法通过英文找中文 eg:getCode("ACERS")==交流电气化铁路系统
     * @param code
     * @return
     */
    public static String getLabelBycode(String code) {
        AcInterferenceSourceTypeEnum rs[] = AcInterferenceSourceTypeEnum.values();
        for (int i = 0; i < rs.length; i++) {
            if (rs[i].toString().equals(code)) {
                return rs[i].getLabel();
            }
        }
        return null;
    }

    public static boolean containsCode(String code) {
        AcInterferenceSourceTypeEnum rs[] = AcInterferenceSourceTypeEnum.values();
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < rs.length; i++) {
            sb.append(rs[i].toString()).append(",");
        }
        sb.deleteCharAt(sb.length() - 1);
        return  sb.toString().contains(code);
    }


}
